﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace SQLTouch.Service.DataContracts
{
    [DataContract]
    public struct GroupByData : IEquatable<GroupByData>
    {
        [DataMember]
        private readonly string column;

        public GroupByData(string column)
        {
            this.column = column;
        }

        public string Column
        {
            get { return column ?? string.Empty; }
        }

        public override string ToString()
        {
            return column;
        }

        public bool Equals(GroupByData other)
        {
            return this.Column == other.Column;
        }

        public override int GetHashCode()
        {
            return this.Column.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj is GroupByData)
            {
                return Equals((GroupByData)obj);
            }
            else
            {
                return false;
            }
        }

        public static bool operator ==(GroupByData left, GroupByData right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(GroupByData left, GroupByData right)
        {
            return !(left == right);
        }
    }
}
